<template>
	<view class="flex_row m-b-12px Comment_Box">
		<view class="Comment">
			<image class="Comment_img" :src="copy_item['imageUrl']" mode=""></image>
		</view>
		<view class="Comment_Box_cont">
			<view class="Comment_Box_cont_top">
				<text class="Comment_Box_cont_top_left">{{copy_item['nickName']}}
					<text v-if="copy_item['isAuthor']==1" class="zuozhe">作者</text>
				</text>
				<QS-Icons v-if="copy_item['isComment']==1" @tap="like" :type="copy_item['commentHitState'] == 1?'love-fill':'love'" fontSize="24px"
					color="#f5205c">
				</QS-Icons>
			</view>
			<view class="Comment_Box_cont_bottom">
				<text style="font-size: 28upx;color: rgba(0, 0, 0, 0.61);"
					class="Comment_Box_cont_bottom_left">{{copy_item['commentContent'] || ''}}</text>
				<text v-if="copy_item['isComment']==1" class="Comment_Box_cont_bottom_right">{{copy_item['commentPraseCount'] || 0}}</text>
			</view>
			<view v-if="copy_item['isComment']==1" class="replay_box">
				<text v-if="copy_item['commentReplyNumber']>0 && !copy_item['childListField']" @tap="seemm(copy_item)"
					class="seemore">查看{{copy_item['commentReplyNumber']}}条回复</text>
				<text v-else class="seemore"></text>
				<text class="tore" @tap="reply(copy_item['id'])">回复</text>
			</view>

			<QS-P height="8px"></QS-P>
			<!-- <text class="fs-14px c-333">{{copy_item['childListField']}}88888</text> -->
			<!-- 二级评论↓ -->
			<block v-if="copy_item['childListField'] && copy_item['childListField'].length">
				<QS-P height="12px"></QS-P>
				<comment-item v-for="(ite, ind) in copy_item['childListField']" :key="ite['idField']" :item="ite"
					:type="type" :index="`${index}.${ind}`">
				</comment-item>
			</block>
		</view>

		<view v-if="copy_item['isComment']==1" class="Comment_Box_bar"></view>
		<!-- <QS-P width="8px"></QS-P> -->
		<!-- <view style="background-color: #000000" class="flex_1 w-flex flex_column"> -->
		<!-- <view class="flex_row">
				<text class="fs-14px c-666">{{copy_item[nameField] || ''}}</text>
			</view> -->
		<!-- <QS-P  height="2px"></QS-P> -->
		<!-- <view class="flex_row_between_c">
				<view class="flex_row_none_c">
					<text class="fs-12px c-999">{{copy_item[dateField] || ''}}</text>
					<QS-P width="24px"></QS-P>
				</view>
				<view class="flex_row_e_c" @tap="like">
					<text class="fs-12px c-666">{{copy_item[likeCountField] || 0}}</text>
					<QS-P width="4px"></QS-P>
					<QS-Icons :type="copy_item[isLikeField]?'love-fill':'love'" fontSize="14px" color="#f5205c">
					</QS-Icons>
				</view>
			</view> -->
		<!-- <QS-P height="8px"></QS-P> -->
		<!-- <text class="fs-14px c-333">{{copy_item[contentField] || ''}}</text> -->
		<!-- 二级评论↓ -->
		<!-- <block v-if="copy_item[childListField] && copy_item[childListField].length">
				<QS-P height="12px"></QS-P>
				<comment-item v-for="(ite, ind) in copy_item[childListField]" :key="ite[idField]" :item="ite"
					:type="type" :index="`${index}.${ind}`">
				</comment-item>
			</block> -->

		<!-- </view> -->
	</view>
</template>

<script>
	export default {
		name: "comment-item",
		props: {
			type: {
				type: String,
				default: ''
			},
			item: {
				type: Object,
				default: () => ({})
			},
			index: {
				type: [Number, String],
			},
			nameField: {
				String,
				default: 'name'
			},
			dateField: {
				type: String,
				default: 'time'
			},
			likeCountField: {
				type: String,
				default: 'likeCounts'
			},
			imageUrlld: {
				type: String,
				default: 'imageUrl'
			},
			contentField: {
				type: String,
				default: 'content'
			},
			childListField: {
				type: String,
				default: 'childList'
			},
			idField: {
				type: String,
				default: 'id'
			},
			isLikeField: {
				type: String,
				default: 'isLike'
			},
			radom: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				copy_item: {
					...this.item
				}
			};
		},
		watch: {
			item: {
				handler(newitem, old) {
					// console.log(newitem, old, 777777)
					this.copy_item = {...this.item}
				},
				deep: true
			},
			radom: {
				handler(newitem, old) {
					// console.log(newitem, old, 66666666, this.item)
					this.copy_item = {...this.item}
					// console.log(this.copy_item,8)
				},
				deep: true
			},
		},
		methods: {
			reply(id) {
				console.log(id)
				uni.$emit('comment-reply', {
					type: this.type,
					data: {
						...this.item,
						update: () => {
							this.copy_item = {
								...this.item
							}
						}
					},
					index: this.index
				});
			},
			seemm(item) {
				this.$emit('seeRely', {
					item,
					update: () => {
						this.copy_item = {
							...this.item
						}
					}
				})
			},
			like() {
				// console.log("ssssssssssssssssss",this.index)
				// uni.$emit(
				// 	'comment-like', {
				// 		type: this.type,
				// 		data: this.item,
				// 		changeLike: () => {
				// 			// console.log(this.copy_item.isLike)
				// 			this.copy_item.isLike = !this.copy_item.isLike;
				// 			if (!this.copy_item.isLike) this.copy_item.likeCounts = this.copy_item.likeCounts - 1;
				// 			else this.copy_item.likeCounts = this.copy_item.likeCounts + 1;

				// 			return this.copy_item.likeCounts;
				// 		},
				// 		index: this.index
				// 	});
				this.$emit('commentLike', {
					type: this.type,
					data: this.copy_item,
					changeLike: () => {
						// this.copy_item.commentHitState = !this.copy_item.commentHitState;
						if (this.copy_item.commentHitState == 1) this.copy_item.commentHitState = 0;
						else if (this.copy_item.commentHitState == 0) this.copy_item.commentHitState = 1
						if (this.copy_item.commentHitState == 0) this.copy_item.commentPraseCount = this
							.copy_item
							.commentPraseCount - 1;
						else this.copy_item.commentPraseCount = this.copy_item.commentPraseCount + 1;
						console.log(this.copy_item.commentHitState)
						return this.copy_item.commentPraseCount;
					},
					index: this.index
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import '@/mypUI/base.scss';
	@import "@/static/css/index-px.scss";

	// #ifndef APP-NVUE
	page {
		// #ifndef APP-NVUE
		min-height: 100vh;
		// #endif
		background-color: #F5F5F5;
	}

	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
	}

	view,
	scroll-view,
	swiper,
	swiper-item,
	cover-view,
	cover-image,
	icon,
	text,
	rich-text,
	progress,
	button,
	checkbox,
	form,
	input,
	label,
	radio,
	slider,
	switch,
	textarea,
	navigator,
	audio,
	camera,
	image,
	video,
	picker-view,
	picker-view-column {
		box-sizing: border-box;
	}

	image {
		display: block;
	}

	// #endif

	.page {
		// #ifdef APP-NVUE
		// flex: 1;
		// #endif
		// #ifndef APP-NVUE
		min-height: 100vh;
		// #endif
		background-color: #F5F5F5;
	}

	.page-ffffff {
		// #ifdef APP-NVUE
		// flex: 1;
		// #endif
		// #ifndef APP-NVUE
		min-height: 100vh;
		// #endif
		background-color: #FFFFFF;
	}

	/*每个页面公共css */

	.d-b {
		// #ifndef APP-NVUE
		display: block;
		// #endif
	}

	// white-space w-s
	.w-s-n {
		// #ifndef APP-NVUE
		white-space: nowrap;
		// #endif
	}

	// input
	.input-row {
		height: 24.5px;
		border-bottom: 1px solid #E5E5E5;
	}

	// font-family f-f
	.f-f-Arial {
		font-family: Arial;
	}

	// font-style f-st
	.f-st-italic {
		font-style: italic;
	}

	// width w
	.w-750rpx {
		width: 750rpx;
	}

	.w-flex {
		// #ifndef APP-NVUE
		width: 0;
		// #endif
	}

	// height h
	.h-flex {
		// #ifndef APP-NVUE
		height: 0;
		// #endif
	}

	// position ps
	.ps-r {
		position: relative;
	}

	.ps-a {
		position: absolute;
	}

	.ps-f {
		position: fixed;
	}

	.ps-s {
		position: sticky;
	}

	.text-bottom {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: flex-end;
	}

	.search-box {
		border-radius: 100px;
		border: 1px solid #EEEEEE;
		height: 29px;
	}

	.full {
		// #ifdef APP-NVUE
		flex: 1;
		// #endif
		// #ifndef APP-NVUE
		height: 100%;
		width: 100%;
		// #endif
	}

	.t-of-e-1 {
		text-overflow: ellipsis;
		overflow: hidden;
		// #ifdef APP-NVUE
		lines: 1;
		// #endif
		// #ifndef APP-NVUE
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		// #endif
	}

	.checkbox {
		transform: scale(.7);
	}

	.line-solid {
		flex: 1;
		height: 0;
		border-top-width: 1px;
		border-top-style: solid;
		border-color: #E5E5E5;
	}

	.mini-checkbox {
		height: 12px;
		width: 12px;
		border-radius: 50%;
		border-width: 4px;
		border-style: solid;
		border-color: #999999;

		&.select {
			border-color: #61B665;
		}
	}

	// text-align a-t
	.t-a-r {
		text-align: right;
	}

	.t-a-l {
		text-align: left;
	}

	.t-a-c {
		text-align: center;
	}

	// font-weight f-w
	.f-w-bold {
		font-weight: bold;
	}

	.f-w-500 {
		font-weight: 500;
	}

	// fixed-bottom f-b
	.fixed-bottom,
	.f-b {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 750rpx;
	}

	// border b
	.b-2_5px-s-ffffff {
		border: 2.5px solid #FFFFFF;
	}

	// border-bottom b-b
	.b-b-1px-solide-e5e5e5 {
		border-bottom: 1px solid #E5E5E5;
	}

	// border b
	.b-1px-solide-e5e5e5 {
		border: 1px solid #E5E5E5;
	}

	// border-color b-c
	.b-c-e5e5e5 {
		border-color: #E5E5E5;
	}

	// color c
	.c-333333,
	.c-333 {
		color: #333333;
	}

	.c-666666,
	.c-666 {
		color: #666666;
	}

	.c-888888,
	.c-888 {
		color: #888888;
	}

	.c-999999,
	.c-999 {
		color: #999999;
	}

	.c-007aff {
		color: #007AFF;
	}

	.c-ffffff,
	.c-fff {
		color: #FFFFFF;
	}

	.c-d40000 {
		color: #D40000;
	}

	.c-000000,
	.c-000 {
		color: #000000;
	}

	.c-ff6b00 {
		color: #FF6B00;
	}

	.c-15BE50 {
		color: #15BE50;
	}

	.c-primary {
		color: $uni-color-primary;
	}

	// backgroundColor bgc bgColor
	.bgc-fff,
	.bgc-ffffff,
	.bgColor-fff,
	.bgColor-ffffff {
		background-color: #FFFFFF;
	}

	.bgColor-f5f5f5,
	.bgc-f5f5f5 {
		background-color: #F5F5F5;
	}

	.bgc-000,
	.bgc-000000,
	.bgColor-000,
	.bgColor-000000 {
		background-color: #000000;
	}

	.bgc-eee,
	.bgc-eeeeee,
	.bgColor-eee,
	.bgColor-eeeeee {
		background-color: #EEEEEE;
	}

	.bgc-FF6B00,
	.bgColor-FF6B00 {
		background-color: #FF6B00;
	}

	.bgc-FF0000,
	.bgColor-FF0000 {
		background-color: #FF0000;
	}

	.bgc-61B665 {
		background-color: #61B665;
	}

	.bgc-FF6B00-_1,
	.bgColor-FF6B00_1 {
		background-color: rgba(255, 107, 0, 0.1);
	}

	.bgc-007AFF-_1,
	.bgColor-007AFF-_1 {
		background-color: rgba(0, 122, 255, 0.1);
	}

	.bgc-15BE50-_1,
	.bgColor-15BE50-_1 {
		background-color: rgba(21, 190, 80, 0.1);
	}


	// flex
	.flex_row {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
	}

	.flex_column {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
	}

	.flex_row_c_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: center !important;
		align-items: center !important;
	}

	.flex_column_c_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: center !important;
		align-items: center !important;
	}

	.flex_column_none_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		align-items: center !important;
		// justify-content: flex-start;
	}

	.flex_column_e_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: flex-end !important;
		align-items: center !important;
	}

	.flex_row_none_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		align-items: center !important;
		// justify-content: flex-start;
	}

	.flex_row_none_e {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		align-items: flex-end !important;
		// justify-content: flex-start;
	}

	.flex_row_none_s {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		align-items: flex-start !important;
		// justify-content: flex-start;
	}

	.flex_row_e_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: flex-end !important;
		// align-items: flex-start;
	}

	.flex_row_c_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: center !important;
	}

	.flex_row_between_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: space-between !important;
		align-items: center !important;
	}

	.flex_row_around_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: space-around !important;
		align-items: center !important;
	}

	.flex_row_s_s {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: flex-start !important;
		align-items: flex-start !important;
	}

	.flex_column_between_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: space-between !important;
		align-items: center !important;
	}

	.flex_column_between_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: space-between !important;
		// align-items: flex-start;
	}

	.flex_column_around_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: space-around !important;
		// align-items: flex-start;
	}

	.flex_column_between_e {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: space-between !important;
		// align-items: flex-end;
	}

	.flex_column_e_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: flex-end !important;
		// align-items: flex-start;
	}

	.flex_column_c_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		justify-content: center !important;
		// align-items: flex-start;
	}

	.flex_column_none_e {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column !important;
		align-items: flex-end !important;
		// justify-content: flex-start;
	}

	.flex_row_e_c {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: flex-end !important;
		align-items: center !important;
	}

	.flex_row_c_e {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: center !important;
		align-items: flex-end !important;
	}

	.flex_row_between_e {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: space-between !important;
		align-items: flex-end !important;
	}

	.flex_row_between_none {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row !important;
		justify-content: space-between !important;
		// align-items: flex-start;
	}

	.flex_1 {
		flex: 1 !important;
	}

	// flex-wrap fw-w
	.fw-w {
		flex-wrap: wrap;
	}

	.Comment_Box {
		position: relative;
		padding: 18upx;
		padding-left: 32upx;
	}

	.Comment_Box_bar {
		position: absolute;
		bottom: 0;
		right: 0;
		width: 580upx;
		height: 2upx;
		background-color: rgba(151, 151, 151, 0.25);
	}

	.Comment {
		width: 33px;
		height: 33px;
		border-radius: 9999px;
		background-clip: padding-box;
		border-top-left-radius: 999px;
		border-top-right-radius: 999px;
		border-bottom-right-radius: 999px;
		border-bottom-left-radius: 999px;
	}

	.Comment_img {
		width: 33px;
		height: 33px;
		border-radius: 9999upx;
	}

	.Comment_Box_cont {
		padding-left: 12px;
		// width: calc(750upx - 24upx);
		flex: 1;
	}

	.Comment_Box_cont_top {
		flex: 1;
		display: flex;
		align-items: flex-start;
		flex-direction: row;
		justify-content: space-between;
	}

	.Comment_Box_cont_top_left_box {
		// display: flex;
		// align-items: center;
	}

	.zuozhe {
		font-size: 22upx;
		// padding: 2upx;
		color: red;
		margin-left: 10upx;
		// padding-bottom: 2upx;
	}

	.Comment_Box_cont_top_left {
		font-size: 28upx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.9);
		// line-height: 40upx;
	}

	.Comment_Box_cont_bottom {

		display: flex;
		align-items: flex-start;
		flex-direction: row;
		margin-top: 5px;
		justify-content: space-between;
	}

	.Comment_Box_cont_bottom_left {
		font-size: 14px;
		color: #999999;
		width: 420upx;
	}

	.Comment_Box_cont_bottom_right {
		font-size: 28upx;
		color: rgba(0, 0, 0, 0.3);
	}

	.replay_box {
		display: flex;
		align-items: flex-start;
		flex-direction: row;
		margin-top: 5px;
		justify-content: space-between;
		padding: 10upx 20upx;
	}

	.seemore {
		font-size: 28upx;
		display: inline;
	}

	.tore {
		font-size: 24upx;
		display: inline;
	}
</style>
